home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FAQ.SWG / 0020_More MIDI Information.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  3KB  |  79 lines

  1. {
  2. JOHN GUILLORY
  3.  
  4. > - the UART 8250, the chip which is their I/O controller
  5. I don't think they use an 8250 UART chip, yet they are similar.  the MIDI
  6. UART is supposed to be faster than the 8250.
  7.  
  8. > - the MIDI protocol ( as far as there is one ... )
  9. Basically it's like this:  Commands start at 80h the lower 4 bits (nibble)
  10. designate the channel number such that 0 = Channel 1, 0f = 16.  Once a
  11. command is given, it is assumed that that command is in effect Until another
  12. command has been given. eg.
  13.  
  14. $C0 is a command to change the Program number, and I think 80 is note on.
  15. if so, an example from the MIDI would be:
  16.  
  17. 80 33 60 80 33 00 C0 02 80 33 60 80 33 00
  18.  
  19. where the 33 is the note to play For the command 80h and 60 is the
  20. pressure/volume (non-presure sensitive keyboards send 64 For the pressure)
  21. Notes are in the order of a keyboard e.g. 0 would tech. be the first C on
  22. the keyboard, 1 would be a C sharp, 2 = D ..., Although most keyboards
  23. (unless they're their enormous) start w/Middle C at around 36 or so, and any
  24. key above middle C is that much above 36, any key below middle C is that
  25. much below....  in MIDI, you can add an octive to a note by adding 12,
  26. subtract 12 to lower it an octive....
  27.  
  28. To setup keyboards, you can send a System Request command (think its F0 or
  29. something like that...) then an ID and a series of Bytes.  The ID Designates
  30. the manufacturer of the keyboard, such that only the devices With that ID
  31. will respond to that event.
  32.  
  33. Seek the Electronic Musician Magazine, May 1989 I'm told gives an article on
  34. handling the MPU-401 interrupts, as well as lots of source code that I used
  35. to have on the MPU-401 seems to come from this magazine.
  36.  
  37.  
  38. The MIDI is quite easy to Program compared to the Sound blaster where you
  39. have to count of so many clock-tick's etc. the MPU-401 is pretty much a
  40. 'check and see if we can send, then do it...' Type card.  Certain commands
  41. do however take a little time For the devices to process eg. change a Program
  42. # it takes so many ms. For that device to be ready For another command, play
  43. a note, a few ms. before the next one...
  44.  
  45. This can become frustation before you learn how to use it...  (I never could
  46. find out why it'd change the first Program # but none of the rest...<grin>)
  47.  
  48. I/O Address 330h is the Std. (though can change on some MPU-401's) I/O Port
  49. for Data. I/O Address 331 is the Status/Comport.
  50.  
  51. Reading the Status port (331h) and masking 80h will tell you if something is
  52. waiting to be received from the mpu-401. e.g.
  53. }
  54.  
  55. Function Receive_MPU(Var B : Byte) : Boolean;
  56. begin
  57.   if (Port[$331] and $80) = 0 then
  58.   begin
  59.     B := Port[$330];
  60.     Receive_MPU := True;
  61.   end
  62.   else
  63.     Receive_MPU := False;
  64. end;
  65.  
  66. {
  67. To Send a Command to the MPU, you must wait till there's no data in the
  68. buffer... The original code I used to have would flush the data if it was
  69. for some reason present when you'd send a Byte...  here's a rough example of
  70. sending data...
  71. }
  72.  
  73. Procedure Send_MPU(B : Byte);
  74. begin
  75.   Repeat Until (Port[$331] and $80) = 0;
  76.   Port[$330] := B;
  77. end;
  78.  
  79.